#ifndef AIPLAYER_H
#define AIPLAYER_H

#include "Player.h"
#include "Card.h"
#include "Hand.h"
#include <list>
/*!
 * \brief The AIPlayer class represents an AIPlayer this player plase the game by itself
 */

//class created by CP Botha
class AIPlayer:public Player
{
public:
   AIPlayer(Hand, int, game* ,Client*);
   /*!
    * \brief getMove ask AIPlayer for move
    */
   void getMove(bool);
   /*!
    * \brief getBid ask AIPlayer for bid
    */
   void getBid();
   /*!
    * \brief getValidMoves looks at the cards and returns a hand will all valid cards that can be played
    * \return
    */
   Hand getValidMoves(char);
   /*!
    * \brief setLocalHand
    * \param h
    * \return
    */
   bool setLocalHand(Hand h);
   /*!
    * \brief sendBid send bid to AIPlayer
    */
   void sendBid(QStringList,int);//send player the last
   /*!
    * \brief sendMove is called when the game master sends a move to a player
    * \param parameter Card the card that was played
    * \param parameter int the player id
    */
   void sendMove(QStringList,int);//send player last card played
   /*!
    * \brief moveInvalid aler AIPlayer that move was invalid
    */
   void moveInvalid();
   /*!
    * \brief bidInvalid alert player that bid was invalid
    */
   void bidInvalid();
   /*!
    * \brief startDealing alert player that dealing is started
    */
   void startDealing();
   /*!
    * \brief startRedealing alert player that redealing is started
    */
   void startRedealing();
   /*!
    * \brief startBidding alert player that bidding is started
    */
   void startBidding();
   /*!
    * \brief startPlay alert player that play is started
    */
   void startPlay();
   /*!
    * \brief RubberDone
    */
   void RubberDone();

   /*!
    * \brief sendContract send player the winning contract
    */
   void sendContract(QStringList);//bid action,suit,num
   /*!
    * \brief sendGameStatus send Game Status to AIPlayer
    */
   void sendGameStatus(QStringList);



private:
   Hand playedCards;
   int time;
   Bid getOpeningBid();
   Bid getRespondBid();
   list<Bid> playerBids[3];
   list<Card> playerMoves[3];
   Bid partnerLastBid;
   Bid highestBid;
   int partnerIndex; //index of partner bids
   void setHighestBid(Bid);
   int compareBids(Bid,Bid);
   bool opener;
   Hand* currTrick;//save the current trick
   char leadSuit;// saves the current trick suit
   /*!
    * \brief trumpSuit saves the trump suit
    */
   QString trumpSuit;//saves the trump suit

   /*!
    * \brief sendTrickWinner alert player of the trick winner
    */
   void sendTrickWinner(QString);
   /*!
    * \brief setTrumpSuit set the trump suit
    */
   void setTrumpSuit(char);
   /*!
    * \brief sendDummy tell the player who the dummy is
    */
   void sendDummyId(int);
   /*!
    * \brief sendDummyCards send player the dummy hand
    */
   void sendDummyCards(Hand);
   /*!
      * \brief canBeat test if the localhand can beat the card
      * \param card test is localHand can beat this card
      */
     bool canBeat(Hand ,Card *);
   /*!
    * \brief openTrick is called if the player is first to play in the tring
    * \return Card to play
    */
   Card* openTrick(Hand);
   int numInvalidBids;
   /*!
    * \brief getLowestBeatCard returns the lowest card from localHand that can beat a card
    * \param card that needs to be beaten
    * \return Card that can beat parameter card
    */
   Card* getLowestBeatCard(Hand,Card *);
   void sendHand();
   void sendGameWinner(QString);
   void sendScoreUpdate(QString,QString,QString,QString );




};

#endif // AIPLAYER_H
